
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;

/**
 *
 * @author Bjarni
 */
public class DisciplinList extends ObjectList {
    public DisciplinList(){
        
    }
    public Disciplin loadObjectFromFile(String dataObject_String) throws FileNotFoundException{
        ArrayList<String> disciplinData = new ArrayList<String>();
        Scanner disciplinReader = new Scanner(dataObject_String);
        disciplinReader.useDelimiter(";");

        while (disciplinReader.hasNext()) {
            disciplinData.add(disciplinReader.next());
        }

        Disciplin disciplin = new Disciplin(disciplinData.get(0), disciplinData.get(1), Integer.parseInt(disciplinData.get(2)),
                disciplinData.get(3), disciplinData.get(4), disciplinData.get(5));

        return disciplin;
    }
    
        public Disciplin dataObjectToDisciplin(DataObject obj) {
        String disc = obj.toString();
        ArrayList<String> disciplinData = new ArrayList<String>();
        Scanner disciplinReader = new Scanner(disc);
        disciplinReader.useDelimiter(";");

        while (disciplinReader.hasNext()) {
            disciplinData.add(disciplinReader.next());
        }

        Disciplin disciplin = new Disciplin(disciplinData.get(0), disciplinData.get(1), Integer.parseInt(disciplinData.get(2)),
                disciplinData.get(3), disciplinData.get(4), disciplinData.get(5));

        return disciplin;
    }

    //overloader den anden hvis parametret er en arraylist
    public ArrayList<Disciplin> dataObjectToDisciplin(ArrayList<DataObject> temp) {
        ArrayList<Disciplin> list = new ArrayList<Disciplin>();
        for (int i = 0; i < temp.size(); i++) {
            list.add(dataObjectToDisciplin(temp.get(i)));
        }
        return list;
    }
}